package com.mida.bms.report.controller;

import com.mida.bms.report.entity.DocStructReport;
import com.mida.bms.report.process.DocFastWriteProcess;
import com.mida.bms.report.service.DocFastWriteService;
import com.mida.bms.report.vo.PatientInfoParameterVo;
import com.mida.tool.common.result.ListResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 快速写入
 */
@RestController
@RequestMapping("/docFastWrite")
@CrossOrigin
@Slf4j
public class DocFastWriteController {

    @Autowired
    private DocFastWriteService docFastWriteService;

    @Autowired
    private DocFastWriteProcess docFastWriteProcess;

    /**
     * getDocStructTemplateList
     * @param vo
     * @return
     */
    @PostMapping(value = "/getDocStructTemplateList",produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ListResult getDocStructTemplateList(@RequestBody PatientInfoParameterVo vo) {
        ListResult listResult;
        try {
            return docFastWriteService.getDocStructTemplateList(vo);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            listResult = new ListResult();
            listResult.setMessage("getPatientInfo处理失败");
            listResult.setStatus(HttpStatus.BAD_REQUEST.value());
            return listResult;
        }
    }


    /**
     * getHistoryReportList
     * @param vo
     * @return
     */
    @PostMapping(value = "/getHistoryReportList",produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ListResult getHistoryReportList(@RequestBody PatientInfoParameterVo vo) {
        ListResult listResult;
        try {
            return docFastWriteService.getHistoryReportList(vo);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            listResult = new ListResult();
            listResult.setMessage("getHistoryReportList处理失败");
            listResult.setStatus(HttpStatus.BAD_REQUEST.value());
            return listResult;
        }
    }

    /**
     * 根据查询条件、查询患者历史报告列表
     * @param vo
     * @return
     */
    @PostMapping(value = "/gainHistoryReportList",produces = {"application/json;charset=UTF-8"})
    @ResponseBody
    public ListResult<List<DocStructReport>> gainHistoryReportList(
            @RequestBody PatientInfoParameterVo vo) {
        ListResult listResult;
        try {
            return docFastWriteProcess.gainHistoryReportList(vo);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            listResult = new ListResult();
            listResult.setMessage("gainHistoryReportList处理失败");
            listResult.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
            return listResult;
        }
    }
}

